import numpy as np
import matplotlib.pyplot as plt

true_b = 1
true_w = 2
N = 100



#数据生成np
np.random.seed(42)
X = np.random.rand(N, 1)

b = np.random.randn(1)
w = np.random.randn(1)
print(b,w)
# print(X)
epsilon = (.1 *np.random.randn(N, 1))
Y= true_b + X * true_w +epsilon

idx = np.arange(N)
np.random.shuffle(idx)
# print(idx)
train_idx = idx[:int(N*0.8)]
val_idx = idx[int(N*0.8):]

x_train,y_train = X[train_idx], Y[train_idx]
x_val,y_val = X[val_idx], Y[val_idx]

# plt.scatter(x_train,y_train)


yhat = b + w *x_train

# plt.scatter(x_train,yhat)

error = yhat - y_train

loss = (error ** 2) .mean()
print(loss)

plt.show()

from langchain_core.tools.base import ToolOutputMixin


